package fun.zhufn.oldcomm.model.bo;

import fun.zhufn.oldcomm.model.bo.json.JsonList;

/**
 * 线路
 */
public class Path {
    String code, name, time, note;
    Integer endTime = null;

    public JsonList getOrders() {
        return orders;
    }

    public void setOrders(JsonList orders) {
        this.orders = orders;
    }

    boolean isInland, isUp;
    JsonList orders = new JsonList();

    public Integer getEndTime() {
        return endTime;
    }

    public void setEndTime(Integer endTime) {
        this.endTime = endTime;
    }

    Integer day;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public String getNote() {
        return note;
    }

    public Path() {
    }

    public void setNote(String note) {
        this.note = note;
    }

    public boolean isInland() {
        return isInland;
    }

    public void setInland(boolean inland) {
        isInland = inland;
    }

    public boolean isUp() {
        return isUp;
    }

    public void setUp(boolean up) {
        isUp = up;
    }

    public Integer getDay() {
        return day;
    }

    public void setDay(Integer day) {
        this.day = day;
    }

    public Path(String code, String name, boolean isInland, boolean isUp, Integer day, String time, String note) {
        this.code = code;
        this.name = name;
        this.time = time;
        this.note = note;
        this.isInland = isInland;
        this.isUp = isUp;
        this.day = day;
    }
    public Path(String code, String name, boolean isInland, boolean isUp, Integer day, String time, String note, Integer endTime, JsonList orders) {
        this.code = code;
        this.name = name;
        this.time = time;
        this.note = note;
        this.isInland = isInland;
        this.isUp = isUp;
        this.day = day;
        this.endTime = endTime;
        this.orders = orders;
    }
    public String getAmPm() {
        try {
            var t = getTime().split(":");
            if (Integer.parseInt(t[0]) < 12) return "上午";
            else return "下午";
        } catch(Exception ignored) {
            return "错误！";
        }
    }

    public String sayEndTime() {
        try {
            var t = getTime().split(":");
            return (Integer.parseInt(t[0]) - getEndTime()) + "点" + t[1] + "分";
        } catch(Exception ignored) {
            return "未设置！";
        }
    }

    public static final String[] week= new String[]{"周日", "周一", "周二", "周三", "周四", "周五", "周六"};
    public String sayDay() {
        return week[getDay()];
    }
}
